#!/usr/bin/env python
# -*- coding:utf-8 -*-
#@Time  : 2020/8/29 11:14
#@Author: flagdied
#@File  : tousu.py
from scrapy import cmdline
class Item(dict):
    class_name = ''

    def __init__(self, selector, class_name=''):
        super().__init__()
        self._selector = selector
        self.class_name = class_name

    def add_path(self, attr, xpath, begin=0, end=None):
        if end is None:
            self[attr] = self._selector.xpath(xpath).get(begin)
            return
        self[attr] = self._selector.xpath(xpath).getall()[begin:end + 1]

def main():
    cmdline.execute('scrapy crawl spider_tousu -o complaints.json'.split())
    # item=Item('a')
    # print(type(item) == Item)
    # print(type(item))


if __name__ == '__main__':
    main()